<* local admin = false if ( not isGuestAccount ( user ) ) then if ( hasObjectPermissionTo ( "user."..getAccountName ( user ), "command.getscreen", false ) ) then admin = true end end *> <*= call ( getResourceFromName("ajax"), "start", getResourceName(getThisResource()) ) *> <* local db = dbConnect ( "sqlite", "conf\\settings.db" ) function htmlspecialchars ( string ) string = string.gsub ( string, "&", "&" ) string = string.gsub ( string, '"', """ ) string = string.gsub ( string, "<", "<" ) return tostring ( string.gsub ( string, ">", ">" ) ) end function getformdata ( name, default, min, max ) if ( form[name] and tonumber ( form[name] ) ) then local t = tonumber ( form[name] ) if ( t >= min and t <= max ) then return t end end return default end function exec ( q, ... ) dbExec ( db, q, ... ) end function query ( q, ... ) local handle = dbQuery ( db, q, ... ) local result = dbPoll ( handle, -1 ) dbFree ( handle ) return result or {} end if ( form['delete'] and admin ) then local id = tonumber ( form['delete'] ) if ( id ) then exec ( "DELETE FROM screenshots WHERE rowid="..id ) end end local players = query ( "SELECT DISTINCT player FROM screenshots WHERE player IS NOT NULL ORDER BY player ASC" ) local admins = query ( "SELECT DISTINCT admin FROM screenshots WHERE admin IS NOT NULL ORDER BY admin ASC" ) local order_columns = { 'time', 'player', 'admin' } local order_dirs = { 'DESC', 'ASC' } local search_player = getformdata ( 'player', 0, 0, table.getn ( players ) ); local search_admin = getformdata ( 'admin', 0, 0, table.getn ( admins ) ); local search_order = getformdata ( 'order', 1, 1, 3 ); local search_direction = getformdata ( 'direction', 1, 1, 2 ); local search_show = getformdata ( 'show', 10, 10, 30 ); local q = "FROM screenshots WHERE 1=1" if ( search_player > 0 and players[search_player].player ) then q = q.." AND player='"..players[search_player].player.."'" end if ( search_admin > 0 and admins[search_admin].admin ) then q = q.." AND admin='"..admins[search_admin].admin.."'" end local count = query ( "SELECT COUNT(*) as count "..q )[1].count local pages = math.ceil ( count / search_show ) if ( pages <= 0 ) then pages = 1 end local search_page = getformdata ( 'page', 1, 1, pages ) local data = query ( "SELECT rowid, * "..q.." ORDER BY "..order_columns[search_order].." "..order_dirs[search_direction].." LIMIT "..( ( search_page - 1 ) * search_show )..","..search_show ) destroyElement ( db ) -- it better not fail before it gets here, stupid mta! *> <* for id, row in ipairs ( data ) do local time = getRealTime ( row.time ) local real_time = string.format ( "%.2d.%.2d.%.2d at %.2d:%.2d", time.monthday, time.month + 1, time.year + 1900, time.hour, time.minute ) *>
Screenshot

Player: <*=htmlspecialchars ( row.player )*> <* if ( admin ) then *> Delete <* end *>

<*=row.description*>

Taken by <*=htmlspecialchars ( row.admin )*> <* if ( row.time ) then *> on <*=real_time*> <* end *>

<* end *>